Skip to content

C#: Simplify extraction of is expressions and case statements#1370

Merged
semmle-qlci merged 4 commits into
github:masterfrom
hvitved:csharp/is-case-extraction
Jun 3, 2019
Merged

C#: Simplify extraction of is expressions and case statements#1370
semmle-qlci merged 4 commits into
github:masterfrom
hvitved:csharp/is-case-extraction

Conversation

@hvitved

@hvitved hvitved commented May 28, 2019

Copy link
Copy Markdown
Contributor

Follow-up on a1e58ce.

@hvitved hvitved added the C# label May 28, 2019
@hvitved hvitved requested a review from calumgrant May 28, 2019 11:21
@hvitved hvitved requested a review from a team as a code owner May 28, 2019 11:21
@pavgust

pavgust commented May 28, 2019

Copy link
Copy Markdown
Contributor

This pull request introduces 1 alert when merging c0a9204 into 9fb61d5 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

Comment posted by LGTM.com

@hvitved hvitved force-pushed the csharp/is-case-extraction branch from c0a9204 to 741380e Compare May 28, 2019 14:57
@hvitved hvitved added this to the 1.21.0 milestone May 29, 2019

@calumgrant calumgrant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small suggestions, but overall it's great to remove the complex logic from expr_parent_adjusted

VariableDeclaration(IExpressionInfo info) : base(info) { }

public static VariableDeclaration Create(Context cx, ISymbol symbol, Type type, Extraction.Entities.Location exprLocation, Extraction.Entities.Location declLocation, bool isVar, IExpressionParentEntity parent, int child)
public static VariableDeclaration Create(Context cx, ISymbol symbol, Type type, TypeSyntax mention, Extraction.Entities.Location exprLocation, Extraction.Entities.Location declLocation, bool isVar, IExpressionParentEntity parent, int child)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it clear that mention is maybe null. Perhaps rename to optionalMention or add some doc comment.

break;
case DiscardDesignationSyntax discard:
new Expressions.Discard(cx, discard, this, 0);
if (!isVar)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swap the then-else arms to remove the ! ?

calumgrant
calumgrant previously approved these changes Jun 3, 2019

@calumgrant calumgrant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@semmle-qlci semmle-qlci merged commit 4bfe89c into github:master Jun 3, 2019
@hvitved hvitved deleted the csharp/is-case-extraction branch June 3, 2019 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants